﻿@model Auction_Intranet.Models.BidResultAdminModel

@{
    ViewBag.Title = "Bids results";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

<h2>Bid results</h2>

@{Html.RenderPartial("_Statistics_RoomMenu", Model.Rooms);}

<h3>All Rooms : @Model.CurrentDateResult.ToLongDateString()</h3>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm("GetBidResultsByDateAllRooms", "Admin", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <div class="editor-label">
        @Html.LabelFor(model => model.postData.bidDate)
    </div>
    <div class="editor-field">
        @Html.TextBoxFor(model => model.postData.bidDate, new { @class = "datepicker", autocomplete = "off", placeholder = "Bid date" })
        @Html.ValidationMessageFor(model => model.postData.bidDate)
    </div>        
    @Html.HiddenFor(model => model.postData.RoomId);
    <input type="submit" value="Get" title="Get Bids" style="width: 80px;"/>
}
<a class="print" href="#" title="Print table">Print table</a>
<table>
    <tr>
        <th>
            Times
        </th>
        @foreach (var room in Model.Rooms)
        {
        <th>
            @room.Name
        </th>
        }

    </tr>
@foreach (var item in Model.Times) {
    <tr>
        <td>
           @item.Startime.ToShortTimeString() - @item.Endtime.ToShortTimeString()
        </td>    
        @foreach (var room in Model.Rooms)
        {
            var tempResult = Model.Bids.Where(x => x.RoomId == room.Id && (x.StartTime == item.Startime || (x.StartTime < item.Startime && x.EndTime >= item.Endtime))).FirstOrDefault();             
            if (tempResult != null)
            {
                <td>  
                    @tempResult.Group.Name
                </td>
            }
            else
            {
                <td>  
                </td>
            }
        }        
    </tr>
}

</table>

<script type="text/javascript">

    $(function () {
        $.datepicker.setDefaults({
            dateFormat: 'dd/mm/yy'
        });

        $(".datepicker").datepicker();
    });

</script>